$(function () {
    layui.use('carousel', function () {
        var carousel = layui.carousel;

        function are() {
            $.ajax({
                url: 'http://localhost:8888/api/swipers',
                type: 'GET',
                success: function (res) {
                    if (res.status === 0) {
                        var arr = []
                        res.data.forEach(function (obj) {
                            arr.push(`
                      <li class="img-effect">
                        <a href="javascript:;">
                          <img src="${'http://localhost:8888/uploads/' + obj.swiperimg}" alt="">
                        </a>
                      </li>
                    `)
                        })
                        $('#kr_carousel ul').html(arr.join(''))
                        // 轮播交互
                        carousel.render({
                            elem: '#kr_carousel',
                            width: 720,
                            height: 300,
                            interval: 3000,
                        })
                    }
                }
            })
        }
        are();

        //友情链接
        function ara() {
            $.ajax({
                url: 'http://localhost:8888/api/links',
                type: 'GET',
                success(res) {
                    if (res.status === 0) {
                        var arr = ['<dt>合作伙伴</dt>'];
                        res.data.forEach(function (obj) {
                            arr.push(`<dd>
                           <a href="javascript:;">
                             <img src="${'http://localhost:8888/uploads/' + obj.linkicon}" alt="">
                           </a>
                         </dd>`);


                        })
                        $('.kr_collaborator').html(arr.join(''))

                    }
                }
            })
        }
        ara();
    });

})

